<template>
	<div class="news">
		<h2>我是News组件，一共有{{$store.getters['xinwen/total']}}条</h2>
		<button @click="addNews">添加一条新闻</button>
		<ul>
			<li v-for="news in newsList">{{news}}</li>
		</ul>
	</div>
</template>

<script>
	export default {
		name:'News',
		computed: {
			newsList(){
				return this.$store.state.xinwen.list
			}
		},
		methods: {
			addNews(){
				this.$store.dispatch('xinwen/jia')
			}
		},
	}
</script>

<style scoped>
.news{
		background-color: orange;
		padding: 20px;
	}
</style>